package com.example.homeworkmutualevaluation.Service;

import com.example.homeworkmutualevaluation.Dao.TeachingDao;
import com.example.homeworkmutualevaluation.Entity.Teaching;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TeachingService {
    @Resource
    private TeachingDao teachingDao;
    public boolean isTeaching(String tphone, String cno) {
        return teachingDao.findByTphoneAndCno(tphone, cno) != null;
    }
    public boolean allocate(String tphone, String cno) {
        if (isTeaching(tphone, cno)) return false;
        else return teachingDao.insert(tphone, cno) > 0;
    }
    public boolean delete(String tphone, String cno) {
        return teachingDao.delete(tphone, cno) > 0;
    }
    public List<Teaching> findAll() {
        return teachingDao.findAll();
    }
    public int countByCno(String cno) {
        return teachingDao.countByCno(cno);
    }
}
